<?php

function selfil($format){
	switch ($format) {

		case 'default':
			?>
			<link href="engine/select/select2.css" rel="stylesheet" type="text/css" />
			<link href="engine/select/select2-bootstrap.css" rel="stylesheet" type="text/css" />	
			<script type="text/javascript" src="engine/select/select2.js"></script>					
			<script type="text/javascript">
			jQuery(document).on("xcrudbeforerequest", function(event, container) {
				if (container) {
					jQuery(container).find("select").select2("destroy");
				} else {
					jQuery(".xcrud").find("select").select2("destroy");
				}
			});
			jQuery(document).on("ready xcrudafterrequest", function(event, container) {
				if (container) {
					jQuery(container).find("select").select2();
				} else {
					jQuery(".xcrud").find("select").select2();
				}
			});
			jQuery(document).on("xcrudbeforedepend", function(event, container, data) {
				jQuery(container).find('select[name="' + data.name + '"]').select2("destroy");
			});
			jQuery(document).on("xcrudafterdepend", function(event, container, data) {
				jQuery(container).find('select[name="' + data.name + '"]').select2();
			});
			</script>
			<?php			
		break;
		case 'fixdep':
			?>
			<link href="engine/select/select2.css" rel="stylesheet" type="text/css" />
			<link href="engine/select/select2-bootstrap.css" rel="stylesheet" type="text/css" />			
			<script type="text/javascript" src="engine/select/select2.js"></script>
			<script type="text/javascript">
			$(document).on("ready xcrudafterrequest",function(){
			    $("select").select2();
			})			
			</script>
			<?php
		break;
	}
}
	
function anoMes($value){
		return date('m/Y', strtotime($value));
}
?>